import 'package:equatable/equatable.dart';
import 'package:flutter_module/model/article.dart';
import 'package:flutter_module/model/article_tags.dart';

enum PostStatus { initial, success, failure }

//先按照github提供的demo进行临摹，熟练之后再根据业务进行调整
class SecondState extends Equatable {
  const SecondState({
    this.status = PostStatus.initial,
    this.datas = const <Article<ArticleTags>>[],
    this.canLoadMore = true,
  });

  final PostStatus status;
  final List<Article<ArticleTags>> datas;
  final bool canLoadMore;

  //自定义 copy 方法，拷贝一个新对象返回。
  SecondState copyWith(
      {PostStatus? status,
      List<Article<ArticleTags>>? datas,
      bool? canLoadMore}) {
    return SecondState(
      status: status ?? this.status,
      datas: datas ?? this.datas,
      canLoadMore: canLoadMore ?? this.canLoadMore,
    );
  }

  @override
  String toString() {
    return '''PostStatus { status: $status, canLoadMore: $canLoadMore, datas: ${datas.length} }''';
  }

  @override
  List<Object?> get props => [status, datas, canLoadMore];
}
